function [va_disadv, va_adv] = func_output(IJVAm2_sq,IJtype2num,IJVAm1_sq,IJtype1num,jass_iprop_wide)
%This function solves for output for adv. and disadv. students

% the following matrices should have rows as teachers and columns as
% positions
% IJVAm2_sq: va with disadv. students
% IJVAm1_sq: va with adv. students
% IJtype2num: number of disadv. students
% IJtype1num: number of adv. students
% jass_iprop_wide: (teacher index, position index)

i_type2_tot=zeros(length(jass_iprop_wide(:,1)),1);
i_type1_tot=zeros(length(jass_iprop_wide(:,1)),1);
i_type2_stu=zeros(length(jass_iprop_wide(:,1)),1);
i_type1_stu=zeros(length(jass_iprop_wide(:,1)),1);
   for i=1:length(jass_iprop_wide(:,1))
          i_type2_tot(i,1)=IJVAm2_sq(jass_iprop_wide(i,1), jass_iprop_wide(i,2)).* IJtype2num(jass_iprop_wide(i,1), jass_iprop_wide(i,2));
          i_type2_stu(i,1)= IJtype2num(jass_iprop_wide(i,1), jass_iprop_wide(i,2));
          
          i_type1_tot(i,1)=IJVAm1_sq(jass_iprop_wide(i,1), jass_iprop_wide(i,2)).* IJtype1num(jass_iprop_wide(i,1), jass_iprop_wide(i,2));
          i_type1_stu(i,1)= IJtype1num(jass_iprop_wide(i,1), jass_iprop_wide(i,2));
   end
        
   va_disadv=sum(i_type2_tot)/sum(i_type2_stu);
    va_adv=sum(i_type1_tot)/sum(i_type1_stu);
end

